package com.huasan.www.demon.data.service.impl;
import com.huasan.www.demon.util.OnePage;
import com.huasan.www.demon.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.huasan.www.demon.data.dao.UserinfoMapper;
import com.huasan.www.demon.data.service.UserinfoService;

import com.huasan.www.demon.pojo.Userinfo;
import com.huasan.www.demon.pojo.UserinfoExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;

@Service("userinfoService")
public class UserinfoServiceImpl implements UserinfoService{
	
    @Autowired
    private UserinfoMapper userinfoDao;    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userinfo
     *
     * @mbggenerated Thu Jan 23 22:34:48 CST 2014
     */
    public int countByExample(UserinfoExample example){
      return userinfoDao.countByExample(example);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userinfo
     *
     * @mbggenerated Thu Jan 23 22:34:48 CST 2014
     */
    public int deleteByExample(UserinfoExample example){
      return userinfoDao.deleteByExample(example);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userinfo
     *
     * @mbggenerated Thu Jan 23 22:34:48 CST 2014
     */
    public int deleteByPrimaryKey(Long id){
      return userinfoDao.deleteByPrimaryKey(id);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userinfo
     *
     * @mbggenerated Thu Jan 23 22:34:48 CST 2014
     */
    public int insert(Userinfo record){
      return userinfoDao.insert(record);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userinfo
     *
     * @mbggenerated Thu Jan 23 22:34:48 CST 2014
     */
    public int insertSelective(Userinfo record){
      return userinfoDao.insertSelective(record);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userinfo
     *
     * @mbggenerated Thu Jan 23 22:34:48 CST 2014
     */
    public List<Userinfo> selectByExample(UserinfoExample example){
      return userinfoDao.selectByExample(example);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userinfo
     *
     * @mbggenerated Thu Jan 23 22:34:48 CST 2014
     */
    public Userinfo selectByPrimaryKey(Long id){
      return userinfoDao.selectByPrimaryKey(id);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userinfo
     *
     * @mbggenerated Thu Jan 23 22:34:48 CST 2014
     */
    public int updateByExampleSelective(@Param("record") Userinfo record, @Param("example") UserinfoExample example){
      return userinfoDao.updateByExampleSelective(record,example);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userinfo
     *
     * @mbggenerated Thu Jan 23 22:34:48 CST 2014
     */
    public int updateByExample(@Param("record") Userinfo record, @Param("example") UserinfoExample example){
      return userinfoDao.updateByExample(record,example);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userinfo
     *
     * @mbggenerated Thu Jan 23 22:34:48 CST 2014
     */
    public int updateByPrimaryKeySelective(Userinfo record){
      return userinfoDao.updateByPrimaryKeySelective(record);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userinfo
     *
     * @mbggenerated Thu Jan 23 22:34:48 CST 2014
     */
    public int updateByPrimaryKey(Userinfo record){
      return userinfoDao.updateByPrimaryKey(record);
    }

    public OnePage<Userinfo> selectOnePageByExample(UserinfoExample example){
    	int count = userinfoDao.countByExample(example);
    	List<Userinfo> dataList = userinfoDao.selectByExample(example);
    	OnePage<Userinfo> onepage = new OnePage<Userinfo>();
    	onepage.setPage(new Page(example.getLimitStart(), example.getLimitEnd()));
    	onepage.getPage().setCount(count);
    	onepage.setDataList(dataList);
    	return onepage;
    }
}